include ../deds/dedssrc
DEDSSRC := $(addprefix ../deds/, $(DEDSSRC))

include ../detk/detksrc
DETKSRC := $(addprefix ../detk/, $(DETKSRC))

include ../degfx/degfxsrc
DEGFXSRC := $(addprefix ../degfx/, $(DEGFXSRC))

include depuisrc

OBJFILES := $(DEPUISRC:.c=.o) $(DEGFXSRC:.c=.o) $(DETKSRC:.c=.o) $(DEDSSRC:.c=.o)
EXTRASRC := ../deds/deds.c ../detk/detk.c ../degfx/degfx.c ../depui/depui.c
INDENTFILES := $(OBJFILES:.o=.c) $(OBJFILES:.o=.h) $(EXTRASRC)
INDENTBACKUP := $(OBJFILES:.o=.c~) $(OBJFILES:.o=.h~) $(EXTRASRC:.c=.c~)

CFLAGS := -O3 -W -Wall -pedantic -s 
PLATFORM := -DMX_PLATFORM_DEGFX
INCLUDES := -I..

.PHONY : all clean indent allegro mgrx

define delobj 
$(shell del $(subst /,\,$(obj)))
endef

define doindent
$(shell indent -kr -l150 -lp -ts4 -nlps -bap -sob -nhnl -bap -fc1 --ignore-newlines $(subst /,\,$(obj)))
endef

all : libdepui.a

libdepui.a : $(OBJFILES)
	ar rs $@ $^

allegro : PLATFORM := -DMX_PLATFORM_ALLEGRO
allegro : all

mgrx : PLATFORM := -DMX_PLATFORM_GRX
mgrx : all

%.o : %.c
	gcc -c $(INCLUDES) $(CFLAGS) $(PLATFORM) -o $@ $^

clean :
	$(foreach obj, $(OBJFILES), $(delobj))
	-del *.a

indent :
	$(foreach obj, $(INDENTFILES), $(doindent))
	$(foreach obj, $(INDENTBACKUP), $(delobj))



